package cn.hive.udf;

import org.apache.hadoop.hive.ql.exec.UDF;

public class StrMaskUDF extends UDF {

	public String evaluate(String str, int len, String replaceStr) {

		if (str == null || str.trim().length() == 0) {
			return null;
		}
		if (str.length() >= len) {
			return str.substring(0, len) + replaceStr;
		} else {
			return str;
		}

	}

	public static void main(String[] args) {
		StrMaskUDF s = new StrMaskUDF();
		String sss = s.evaluate("哈哈哈哈哈哈哈哈哈", 3, "...");
		System.out.println(sss);
	}
}
